# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=nbclient
pkgbase=mingw-w64-python-jupyter-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-jupyter-${_realname}
pkgver=0.10.2
pkgrel=1
pkgdesc='A client library for executing Jupyter notebooks (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/jupyter/nbclient'
msys2_documentation_url='https://nbclient.readthedocs.io/'
msys2_references=(
  'archlinux: jupyter-nbclient'
  'purl: pkg:pypi/nbclient'
)
license=('spdx:BSD-3-Clause')
depends=(
    "${MINGW_PACKAGE_PREFIX}-python"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter-nbformat"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter_core"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter_client"
    "${MINGW_PACKAGE_PREFIX}-python-traitlets")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling")
options=(!strip)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('90b7fc6b810630db87a6d0c2250b1f0ab4cf4d3c27a299b0cde78a4ed3fd9193')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
